/**
 * @filename:Const 2018年06月01日
 * @project OnlineGame    边鹏  V1.0
 * Copyright(c) 2018 BianP Co. Ltd. 
 * All right reserved. 
 */
package com.xin.dealcenter.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
 * Swagger核心配置文件
 * ========================
 * @author  BianP 
 * Date：2018/1/30
 * Time：23:07
 * ========================
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
	
	public static String CONTROLLER_URL="com.xin.dealcenter.webApi";    //Swagger扫描的接口路径
	public static String SWAGGER_TITLE="JAVA懒开发-BianPeng"; 	    		//Swagger接口文档标题
	public static String SWAGGER_DESCRIPTION="交易中心";   				//Swagger接口文档描述
	public static String SWAGGER_VERSION="1.0";                         //Swagger接口文档版本
	public static String SWAGGER_URL="http://127.0.0.1:8902";           //Swagger项目服务的URL
	//验证的页面http://127.0.0.1:8900/swagger-ui.html
	@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage(CONTROLLER_URL))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title(SWAGGER_TITLE)
                .description(SWAGGER_DESCRIPTION)
                .termsOfServiceUrl(SWAGGER_URL)
                .version(SWAGGER_VERSION)
                .build();
    }
}
